void onReceiveFunction(void)
{
 //String Collect_Data = ""; 
 while(Serial.available()>0)
 {
  char data = Serial.read();
  Serial2.write(data);   //将数据发送到舵机

//  Collect_Data += data;
 }

//  Serial.print(Collect_Data);                     //输出取出的内容
//  Collect_Data = "";                              //清空内容
}

void onReceiveFunction2(void)
{
 while(Serial2.available()>0)
 {
  char data = Serial2.read();
  Serial.write(data);   //将数据发送到串口
 }
}



void setup() 
{
  Serial.begin(115200);        //usb串口
  Serial2.begin(1000000);//腿部sts舵机

  Serial.onReceive(onReceiveFunction);    //为串口设置回调函数
  Serial2.onReceive(onReceiveFunction2);  //为串口设置回调函数
}
 

void loop() 
{

delay(1000);
 
}
  
